package com.better.common.config;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by Administrator on 2018/1/25.
 */
@Component
@Data
@ConfigurationProperties(prefix = "auth")
@PropertySource(value = "classpath:/noprotected.properties", ignoreResourceNotFound = true, encoding = "utf-8")
public class NoProtectedProperties {
    private List<String> noProtectedPaths;
    private List<String> staticResources;

    public String[] getAuthPath() {
        if (CollectionUtils.isNotEmpty(noProtectedPaths)) {
            return StringUtils.join(noProtectedPaths, ",").replace("*", "").split(",");
        }
        return null;
    }
}
